﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BaccaratRally.DataKernel.Entity
{
    [BaccaratRally.DataKernel.Entity.SqlTableAttribute("Account")]
    public class Account : BaccaratRally.DataKernel.Entity.EntityBase
    {

        #region data fields
        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("AccountPos", false, false, false, false)]
        public System.String AccountPos { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("AccountName", false, false, false, false)]
        public System.String AccountName { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("CurrSite", false, false, false, false)]
        public System.String CurrSite { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("IPAddress", false, false, true, false)]
        public System.String IPAddress { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("LastActive", false, false, false, false)]
        public System.DateTime LastActive { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("Online", false, false, false, false)]
        public System.Byte Online { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("TableStatus1", false, false, true, false)]
        public System.Byte TableStatus1 { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("LastChangeTime1", false, false, true, false)]
        public System.DateTime LastChangeTime1 { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("TableStatus2", false, false, true, false)]
        public System.Byte TableStatus2 { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("LastChangeTime2", false, false, true, false)]
        public System.DateTime LastChangeTime2 { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("TableStatus3", false, false, true, false)]
        public System.Byte TableStatus3 { get; set; }

        [BaccaratRally.DataKernel.Entity.SqlFieldAttribute("LastChangeTime3", false, false, true, false)]
        public System.DateTime LastChangeTime3 { get; set; }

        #endregion

        internal override void ReBuildInstance(System.Data.SqlClient.SqlDataReader reader)
        {
            this.AccountPos = GetReaderValue<System.String>(reader, "AccountPos");
            this.AccountName = GetReaderValue<System.String>(reader, "AccountName");
            this.CurrSite = GetReaderValue<System.String>(reader, "CurrSite");
            this.IPAddress = GetReaderValue<System.String>(reader, "IPAddress");
            this.LastActive = GetReaderValue<System.DateTime>(reader, "LastActive");
            this.Online = GetReaderValue<System.Byte>(reader, "Online");
            this.TableStatus1 = GetReaderValue<System.Byte>(reader, "TableStatus1");
            this.LastChangeTime1 = GetReaderValue<System.DateTime>(reader, "LastChangeTime1");
            this.TableStatus2 = GetReaderValue<System.Byte>(reader, "TableStatus2");
            this.LastChangeTime2 = GetReaderValue<System.DateTime>(reader, "LastChangeTime2");
            this.TableStatus3 = GetReaderValue<System.Byte>(reader, "TableStatus3");
            this.LastChangeTime3 = GetReaderValue<System.DateTime>(reader, "LastChangeTime3");
        }

        internal override System.Data.SqlClient.SqlParameter[] BuildInsertParamter()
        {
            BaccaratRally.DataKernel.SqlGateway.DbSqlParamterCollection paramterList = new BaccaratRally.DataKernel.SqlGateway.DbSqlParamterCollection();
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@AccountPos", System.Data.SqlDbType.VarChar, 5));
            paramterList["@AccountPos"].Value = this.AccountPos;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@AccountName", System.Data.SqlDbType.VarChar, 50));
            paramterList["@AccountName"].Value = this.AccountName;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@CurrSite", System.Data.SqlDbType.VarChar, 50));
            paramterList["@CurrSite"].Value = this.CurrSite;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@IPAddress", System.Data.SqlDbType.VarChar, 50));
            paramterList["@IPAddress"].Value = this.IPAddress;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@LastActive", System.Data.SqlDbType.DateTime, 8));
            paramterList["@LastActive"].Value = this.LastActive;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@Online", System.Data.SqlDbType.TinyInt, 1));
            paramterList["@Online"].Value = this.Online;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@TableStatus1", System.Data.SqlDbType.TinyInt, 1));
            paramterList["@TableStatus1"].Value = this.TableStatus1;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@LastChangeTime1", System.Data.SqlDbType.DateTime, 8));
            paramterList["@LastChangeTime1"].Value = this.LastChangeTime1;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@TableStatus2", System.Data.SqlDbType.TinyInt, 1));
            paramterList["@TableStatus2"].Value = this.TableStatus2;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@LastChangeTime2", System.Data.SqlDbType.DateTime, 8));
            paramterList["@LastChangeTime2"].Value = this.LastChangeTime2;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@TableStatus3", System.Data.SqlDbType.TinyInt, 1));
            paramterList["@TableStatus3"].Value = this.TableStatus3;
            paramterList.Add(new System.Data.SqlClient.SqlParameter("@LastChangeTime3", System.Data.SqlDbType.DateTime, 8));
            paramterList["@LastChangeTime3"].Value = this.LastChangeTime3;
            return paramterList.ToArray();
        }

        internal override System.Data.SqlClient.SqlParameter[] BuildUpdateParamter()
        {
            BaccaratRally.DataKernel.SqlGateway.DbSqlParamterCollection paramterList = new BaccaratRally.DataKernel.SqlGateway.DbSqlParamterCollection();
            return paramterList.ToArray();
        }

        internal override string GetInsertCommandText()
        {
            string sqlcmd = @"insert dbo.[Account]([AccountPos],[AccountName],[CurrSite],[IPAddress],[LastActive],[Online],[TableStatus1],[LastChangeTime1],[TableStatus2],[LastChangeTime2],[TableStatus3],[LastChangeTime3])
                          values(@AccountPos, @AccountName, @CurrSite, @IPAddress, @LastActive, @Online, @TableStatus1, @LastChangeTime1, @TableStatus2, @LastChangeTime2, @TableStatus3, @LastChangeTime3)
                          select * from dbo.[Account] where 1=1
                        ";
            return sqlcmd;
        }

        internal override string GetUpdateCommandText()
        {
            string sqlcmd = @"";
            return sqlcmd;
        }
    }

}
